<?php

namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class User extends Model{
    protected $table = "user";
    protected $dateFormat = 'Y-m-d H:i:s';
    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
        'delete_at' => 'datetime:Y-m-d H:i:s',
    ];
    protected $hidden = ['password', 'key'];
    protected $guarded = array('id', 'name','type');
    protected $fillable = ['name','username', 'password','key','company_id','role_ids','type','phone','image','status','age','sex','created_at','updated_at','delete_at','content'];
    public function companyList()
    {
        return $this->belongsTo(Company::class, 'company_id');
    }
    public function rolesList()
    {
        dump('000');

        exit();
        $roleIds = json_decode($this->role_ids, true);
        if ($roleIds) {
            return Role::whereIn('id', [4,5])->pluck('name')->toArray();
        }else{
            return [];

        }
    }
    public function role()
    {
        return $this->hasOne(Role::class,);
    }

}
